home *** CD-ROM | disk | FTP | other *** search
- /*
-
- By Gabriele Speranza: a more easily usable interface to some "hooks" inserted
- into console.c
-
- */
-
-
-
- #include <MacHeaders>
- #include "stdio.h"
- #include "console.h"
-
- void screen_size(int*,int*);
- void set_arrow_cursor(void);
- void config_console(int,int,char*,int,int,int,int,int,int);
- FILE* fopen_win(int,int,char*,int,int,int,int,int);
-
- #define _MBARHEIGHT (ROM85==-1?20:MBarHeight)
- #define _TITLEBARHEIGHT 20
- #define MAX(a,b) (a)<(b)?(b):(a)
- #define hiword(x) (((short *) &(x))[0])
- #define loword(x) (((short *) &(x))[1])
- extern long my_current_size,my_current_A5;
- void init_all(void);
- void __open_std(void);
- void *memcpy(void*, void *, size_t );
-
- /******* screen_size: returns the screen size (Symantec puts QuickDraw globals
- in a nonstandard place, so screenBits contains zeroes...) Really, I could have
- avoided to patch console.c to get the pointer in my_current_A5, by using
- the method that Quickdraw uses to find those data, but when I wrote it I
- did not know how Quickdraw did **********/
-
- void screen_size(width,heigth)
- int* width,*heigth;
- {
- *width= ( (BitMap*)(my_current_A5-122L) )->bounds.right;
- *heigth=( (BitMap*)(my_current_A5-122L) )->bounds.bottom;
- }
-
- /******* set_arrow_cursor: the cursor becomes the usual arrow (arrows contains zeros...*/
- void set_arrow_cursor()
- {
- SetCursor( (Cursor*) (my_current_A5-122L+sizeof(BitMap)) );
- }
-
- /********* config_console: set attributes of the console window ********/
-
- void config_console(top,left, /* position */
- title,
- pId, /* procId, identifies the kind of window */
- rows,cols, /* maximum size */
- cur_rows,cur_cols, /* current size: as you surely know, ANSI library windows
- can be resized, by clicking where the grow box should be;
- to have them smaller than the max size is boring since what
- is outside can't be seen unless you resize them, but if you
- wish an initial size less than the maximum, you can */
- pressreturn /* display or not the "press return to exit" message */
- )
- char *title;
- {
- struct __copt temp;
- int mintop=_MBARHEIGHT + _TITLEBARHEIGHT -4;
-
- memcpy((void*)&temp,(void*)&console_options,sizeof(struct __copt));
- console_options.top=MAX(mintop,top);
- console_options.left=left;
- if(title) console_options.title=title;
- if(pId>=0) console_options.procID=pId;
- console_options.nrows=MAX(rows,cur_rows);
- console_options.ncols=MAX(cols,cur_cols);
- console_options.pause_atexit=pressreturn;
- loword(my_current_size)=cur_rows;
- hiword(my_current_size)=cur_cols;
- __open_std();
- memcpy((void*)&console_options,(void*)&temp,sizeof(struct __copt));
-
- }
-
- /********* fopen_win: open another window and set its attributes ********/
-
- FILE* fopen_win(top,left,title,pId,rows,cols,cur_rows,cur_cols)
- char *title;
- {
- FILE*p;
- struct __copt temp;
- int mintop=_MBARHEIGHT + _TITLEBARHEIGHT -4;
-
- memcpy((void*)&temp,(void*)&console_options,sizeof(struct __copt));
- console_options.top=MAX(mintop,top);
- console_options.left=left;
- console_options.title=title;
- if(pId>=0) console_options.procID=pId;
- console_options.nrows=MAX(rows,cur_rows);
- console_options.ncols=MAX(cols,cur_cols);
- loword(my_current_size)=cur_rows;
- hiword(my_current_size)=cur_cols;
- p=fopenc();
- memcpy((void*)&console_options,(void*)&temp,sizeof(struct __copt));
- return p;
- }
-